﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Text;
using NewThinkings.BusinessLayer.BusinessObject;
using NewThinkings.BusinessLayer.BusinessObject.Core;

namespace Presentation.WebApp.Mods.Front
{
    public class CInterfaceFunctionUI
    {

        #region Private member
        public CInterfaceFunction cIFunction;
        #endregion

        #region Public property

        #endregion

        #region Constructor
        public CInterfaceFunctionUI(CInterfaceFunction _cIFunc)
        {
            cIFunction = _cIFunc;
        }
        public CInterfaceFunctionUI() { }
        #endregion

        #region Dispose

        #endregion

        #region Infomation
        public static string GetInterfaceFunctionImage()
        {
            System.Threading.Thread.Sleep(10);
            string[] css = { "ss_bullet_black", "ss_bullet_blue", "ss_bullet_delete", "ss_bullet_green", "ss_bullet_orange", "ss_bullet_pink", "ss_bullet_purple", " ss_bullet_red", "ss_bullet_yellow" };
            string sprite = string.Format("<span class='ss_sprite {0}'> &nbsp;</span>",
                css[new Random().Next(css.Length)]);
            return sprite;
        }

        public string GetHtml()
        {

            //<div>
            //    <a href="">Nothing1</a>
            //    <a href="">Nothing2</a>
            //</div>

            StringBuilder ret = new StringBuilder();
            ret.Append(string.Format("<a  link='{0}' href='javascript:void(0);' id='IFunc_{1}' tabid='f{1}' iLoad='1' RetainPage='{4}' hideMenu='{5}'>{3} {2}</a>",
                            cIFunction.LinkURL,
                            cIFunction.ID,
                            cIFunction.Name,
                            GetInterfaceFunctionImage(),
                            cIFunction.RetainPage,
                            cIFunction.HideMenu
                            ));
            return ret.ToString();
        }

        #endregion

        #region Infomation - Static
        public static string GetHtml(IList<CInterfaceFunction> listIFunc)
        {
            StringBuilder ret = new StringBuilder();
            ret.Append("<div class='MenuIFunc'>");
            foreach (CInterfaceFunction iFunc in listIFunc)
            {
                CInterfaceFunctionUI CIFunc = new CInterfaceFunctionUI(iFunc);
                ret.Append(CIFunc.GetHtml());
            }
            ret.Append("</div>");
            return ret.ToString();
        }
        #endregion
    }
}